using AutoMapper;
using Core.Db.Dtos;
using Core.Db.Models;

namespace Core.Db.Profiles;

public class TouristRouteProfile : Profile
{
    public TouristRouteProfile()
    {
        CreateMap<TouristRoute, TouristRouteDto>()
            .ForMember(desc => desc.Price,
                opt => opt.MapFrom(src => src.OriginalPrice * (decimal)(src.DiscountPresent ?? 1))
            )
            .ForMember(desc => desc.TravelDays,
                opt => opt.MapFrom(src => src.TravelDays.ToString())
            )
            .ForMember(desc => desc.TripType,
                opt => opt.MapFrom(src => src.TripType.ToString())
            )
            .ForMember(desc => desc.DepatureCity,
                opt => opt.MapFrom(src => src.DepatureCity.ToString())
            );

        CreateMap<TouristRouteForCreationDto, TouristRoute>()
            .ForMember(desc => desc.Id, opt => opt.MapFrom(src => Guid.NewGuid()));

        CreateMap<TouristRouteForUpdateDto, TouristRoute>();

        CreateMap<TouristRoute, TouristRouteForUpdateDto>();
    }
}